/**
 * 
 * @author Travis C lynch <travisclynch@student.midlandstech.edu>
 * @version Jan 19 2012
 * <br>
 * <br>
 * <b>Instructions</b>
 * <p>
 * <ul>
 * <li>since the Blob class implements BlobInterface, then a Blob is a BlobInterface, so a Blob can be passed to the insert method below 
 * <li>A default constructor gives a Box capable of holding up to 25 pounds of Blobs. 
 * <li>An one-int-parameter constructor creates a Box capable of holding that number of pounds, but prints an error message and uses 25 for 0 or negative arguments. 
 * </ul>
 * <b>Discription</b>
 * <p>
 * <ul>
 * <li>A class that implaments the BoxInterface interface
 * </ul>
 * 
 */
public class Box implements BoxInterface {
	double capacity;
	BlobInterface[] array = new BlobInterface[100];
	int idx = 0;
	
	// Constructors
	public Box(){
		capacity = 25;
	}
	/**
	 * @param c Capacity of the box to be use in the constructor
	 */
	public Box(double c){
		if(c<0 || c>25){
			capacity = 25;
			System.out.println("Error: Exceted Max Capacity. A 25 Lbs capacity Box was created!");
		}else{
			capacity = c;
		}
	}

	public boolean insert(BlobInterface b) {
		// TODO Auto-generated method stub
		if(!(b.getWeight()>this.remainingCapacity())){
			array[idx++] = b;
			return true;
		}
		return false;
	}

	public void printContents() {
		// TODO Auto-generated method stub
		for(int i=0;i<idx;i++){
			System.out.println("Blob that is " + array[i].getWeight() + " Lbs");
		}
	}
	// accessor Methods
	/**
	 * @return remaining compacity in the box
	 */
	public double remainingCapacity() {
		// TODO Auto-generated method stub
		return this.capacity-this.addContents();
	}
	private double addContents(){
		double totalWeight=0;
		for(int i=0;i<idx;i++){
			totalWeight += array[i].getWeight();
		}
		return totalWeight;
	}

}
